<?php

//No direct access

defined('_JEXEC') or die('Restricted access');

$priceformat = OwnserviceHelper::getParams('price_format', '#,###.##');

$dateformat  = OwnserviceHelper::getParams('date_format', '%d/%m/%Y'); 

?>

<div id="ownservices">


 <div id="mainmenuownservice"><?php echo MenuHelper::nav(); ?></div>


	<div id="mainownservice">
		<div id="print">
			<table width="100%">
				<tr>
					<td align="right"><a href="javascript:window.print();"><img src="<?php echo JURI::base().'/components/com_ownservice/assets/images/printer.png'; ?>" alt="<?php echo JText::_('OWNSERVICE_PRINT'); ?>" /></a></td>
				</tr>
			</table>
		</div>
		<h3><?php echo JText::_('OWNSERVICE_TRANSFERRED_RECORD_USER'); ?></h3>

		<hr />

		<form action="<?php echo JRoute::_('index.php?option=com_ownservice'); ?>" method="post" name="adminForm">

			 <table class="admintable">

				<tr>

					<td class="key"><?php echo JText::_('OWNSERVICE_FIRSTNAME'); ?></td>

					<td>

						<strong><?php echo $this->member->name; ?></strong>

					</td>

					<td class="key"><?php echo JText::_('OWNSERVICE_ID'); ?> / <?php echo JText::_('OWNSERVICE_PHONE'); ?></td>

					<td>

						<strong><?php echo $this->member->username; ?> / <?php echo $this->member->phone_no; ?></strong>

					</td>

				</tr>

				<tr>

					<td class="key"><?php echo JText::_('OWNSERVICE_ADDRESS'); ?></td>

					<td>

						<strong><?php echo $this->member->address.' '.$this->member->city.' '.$this->member->state.' '.$this->member->country.' '.$this->member->postcode; ?></strong>

					</td>

					<td class="key"><?php echo JText::_('OWNSERVICE_EMAIL'); ?></td>

					<td>

						<strong><?php echo $this->member->email; ?></strong>

					</td>

				</tr>

				<tr>

					<td class="key"><?php echo JText::_('OWNSERVICE_BIRTHDAY'); ?></td>

					<td>

						<strong><?php echo JHTML::_('date',$this->member->birthday, $dateformat); ?></strong>

					</td>

					<td class="key"><?php echo JText::_('OWNSERVICE_ID_TYPE'); ?> / <?php echo JText::_('OWNSERVICE_ID_NUMBER'); ?></td>

					<td>

						<strong><?php echo $this->member->id_type; ?> / <?php echo $this->member->id_number; ?> </strong>

					</td>

				</tr>

				<tr>

					<td class="key"><?php echo JText::_('OWNSERVICE_EXPIRE_DATE'); ?></td>

					<td><?php echo JHTML::_('date',$this->member->expire_date, $dateformat); ?></td>
					<td class="key"><?php echo JText::_('OWNSERVICE_SELECT_PERIOD'); ?></td>

			<td>

				<strong>

				<?php

					$dateformat  = OwnserviceHelper::getParams('date_format', '%d/%m/%Y'); 

					if($this->data['period'] == 1) {

						echo JHTML::_('date',$this->data['date'], $dateformat);

					} else if($this->data['period'] == 2) {

						echo JText::_('OWNSERVICE_FROM').' '.JHTML::_('date', (' 01-'.$this->data['month'].'-'.date('Y')), $dateformat).' '.JText::_('OWNSERVICE_TO').' '.JHTML::_('date', (date("t", mktime(0,0,0,$this->data['month'],1,date('Y'))).'-'.$this->data['month'].'-'.date('Y')), $dateformat);

					} else if($this->data['period'] == 3) {

						echo JText::_('OWNSERVICE_FROM').' '.JHTML::_('date', $this->data['from'], $dateformat).' '.JText::_('OWNSERVICE_TO').' '.JHTML::_('date', $this->data['to'], $dateformat);

					}

				?>

				</strong>

			</td>

				</tr>

			  </table>

			<table class="adminlist" cellspacing="1">

				<tr> 

				  <td align="center" class="tablelist"><?php echo JText::_('OWNSERVICE_RECEIVER_NO'); ?></td>

				  <td align="center" class="tablelist"><?php echo JText::_('OWNSERVICE_ACCOUNT_NO'); ?></td>

				  <td align="center" class="tablelist"><?php echo JText::_('OWNSERVICE_USER'); ?></td>

				  <td align="center" class="tablelist"><?php echo JText::_('OWNSERVICE_TRANSFER_ON'); ?></td>

				  <?php /*<td align="center" class="tablelist"><?php echo JText::_('OWNSERVICE_STATUS'); ?></td>*/ ?>

				  <td align="center" class="tablelist"><?php echo JText::_('OWNSERVICE_AMOUNT_TRANSFER'); ?><br />

					(AUD)</td>

				  <td align="center" class="tablelist"><?php echo JText::_('OWNSERVICE_RATE'); ?></td>

				  <td align="center" class="tablelist"><?php echo JText::_('OWNSERVICE_TOTAL_EXCHANGE'); ?></td>

				  <td align="center" class="tablelist"><?php echo JText::_('OWNSERVICE_FEE'); ?><br />

					(AUD)</td>

				</tr>

				<?php
					$k = 0;
					$total_amount = 0;

					$total_transfer = 0;

					$total_fee = 0;

					for($i=0,$n=count($this->rows);$i<$n;$i++): 

					$row = $this->rows[$i];

				?>

				<tr class="<?php echo "row$k"; ?>"> 

				  <td align="center" class="inner_tablelist"> <a href="<?php echo JRoute::_('index.php?option=com_ownservice&controller=transaction&task=detail&id='.$row->id); ?>"><?php echo $row->invoice; ?></a> 

				  </td>

				  <td align="center" class="inner_tablelist"><?php echo OwnserviceHelper::accountFormat($row->account); ?></td>

				  <td class="inner_tablelist"><a href="<?php echo JRoute::_('index.php?option=com_ownservice&controller=member&task=detail&id='.$row->proid); ?>"><?php echo $row->username; ?></a></td>

				  <td align="center" class="inner_tablelist"><?php echo JHTML::_('date', $row->created, $dateformat); ?></td>

				  <?php /*<td align="center" class="inner_tablelist"><?php //echo OwnserviceHelper::getStatus($row->id, $row->state); ?></td>*/?>

				  <td class="inner_tablelist" align="center"><?php echo OwnserviceHelper::moneyFormat($priceformat,$row->amount); ?></td>

				  <td class="inner_tablelist" align="right">
					<?php
						$color = '';
						if($row->extrarate > 0.00 ) {
							$color = 'red';
						} else if($row->extrarate < 0.00) {
							$color = 'green';
						}
					?>
					<?php if(!$row->iscore): ?>
					<div style="border-bottom: 1px solid;">
						<?php echo OwnserviceHelper::moneyFormat($priceformat,$row->rate_th); ?> THB
					</div>
					<?php endif; ?>
					<div>
						<span class ="<?php echo $color; ?>"><?php echo OwnserviceHelper::moneyFormat($priceformat,$row->rate+$row->extrarate); ?></span>
						<?php echo $row->rate_code; ?> 
					</div>
				  </td>

				  <td class="inner_tablelist" align="right">
				  <?php
					$color = '';
					$total = 0;
					if($row->extratotal > 0.00 ) {
						$color = 'red';
						$total = $row->extratotal;
					} else {
						$total = $row->amount * ($row->rate+$row->extrarate);
					}
				?>
					<?php if(!$row->iscore): ?>
					<div style="border-bottom: 1px solid;">
						<?php echo OwnserviceHelper::moneyFormat($priceformat,$row->total_th); ?> THB
					</div>
					<?php endif; ?>
					<div>
					<span class="<?php echo $color; ?>">
						<?php echo OwnserviceHelper::moneyFormat($priceformat,($total- ($row->bankfee+$row->extrabfee))); ?>
					</span> <?php echo $row->rate_code; ?>
					</div>
				  </td>

				  <td class="inner_tablelist" align="center">
				  <?php
					$color = '';
					if($row->extrafee > 0.00) {
						$color = 'red';
					} else if($row->extrafee < 0.00) {
						$color = 'green';
					}
				  ?>
				  <span class="<?php echo $color; ?>"><?php echo OwnserviceHelper::moneyFormat($priceformat,$row->fee+$row->extrafee); ?></span>
				  </td>

				</tr>

				<?php

					$total_amount 	= $total_amount + $row->amount;

					$total_fee		= $total_fee + ($row->fee+$row->extrafee);

					if($row->extratotal > 0.00 ) {
							$total_transfer = $total_transfer + ($row->extratotal - ($row->bankfee+$row->extrabfee));
					} else {
							$total_transfer = $total_transfer + (($row->amount * ($row->rate+$row->extrarate))- ($row->bankfee+$row->extrabfee));
					}
					$k = 1 - $k; endfor; 
				?>

				<tr> 

				  <td colspan="4" align="right"><strong><?php echo JText::_('OWNSERVICE_TOTAL'); ?></strong></td>

				  <td align="center"><u><strong><?php echo OwnserviceHelper::moneyFormat($priceformat,$total_amount); ?></u></strong></td>

				  <td align="center"></td>

				  <td align="right"><strong><u><?php echo OwnserviceHelper::moneyFormat($priceformat,$total_transfer); ?></u> <?php echo $row->rate_code; ?></strong></td>

				  <td align="center"><strong><u><?php echo OwnserviceHelper::moneyFormat($priceformat,$total_fee); ?></u></strong></td>

				</tr>

			  </table>



			<input type="hidden" name="option" value="com_ownservice" />

			<input type="hidden" name="task" value="" />

			<input type="hidden" name="Itemid" value="<?php echo JRequest::getVar('Itemid'); ?>" />

			<input type="hidden" name="user_id" value="<?php echo $this->data['user_id']; ?>" />

			<input type="hidden" name="controller" value="report" />

			<input type="hidden" name="view" value="report" />

			<?php echo JHTML::_( 'form.token' ); ?>

		</form>

	</div>

</div>